// src/routers/ProtectedRoute.tsx
import React from 'react';
import { Navigate } from 'react-router-dom';
import { useStore } from '../stores';

interface ProtectedRouteProps {
  children: React.ReactElement;
}

const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => {
  const store = useStore();
  
  // 检查认证状态
  if (!store.auth.isAuthenticated) {
    return <Navigate to="/login" replace />;
  }
  
  return children;
};

export { ProtectedRoute };